package com.itheima.controller;

import com.itheima.common.R;
import com.itheima.domain.OmsOrderReturnApply;
import com.itheima.manager.OmsOrderReturnApplyManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
* 订单退货申请
* */
@RestController
@CrossOrigin(origins = "*")
public class OmsOrderReturnApplyController {

    @Autowired
    OmsOrderReturnApplyManager omsOrderReturnApplyManager;

    //分页查询退货申请
    @GetMapping("/returnApply/list")
    public R findByPage(String createTime, String handleMan, String handleTime, Integer id,
                        Integer pageNum, Integer pageSize, String receiverKeyword, Integer status) {
        return omsOrderReturnApplyManager.findByPage(createTime,handleMan,handleTime,id, pageNum,pageSize,receiverKeyword,status);
    }

    //获取退货申请详情
    @GetMapping("/returnApply/{id}")
    public R getOrderReturn(@PathVariable Long id) {
        return omsOrderReturnApplyManager.getOrderReturn(id);
    }

    //修改退货申请状态
    @PostMapping("/returnApply/update/status/{id}")
    public R updateStatus(@PathVariable Integer id, @RequestBody OmsOrderReturnApply omsOrderReturnApply) {
        omsOrderReturnApplyManager.updateStatus(id, omsOrderReturnApply);
        return R.success("修改成功");
    }

    //批量删除退货申请
    @PostMapping("/returnApply/delete")
    public R delete(@RequestParam List<Long> ids) {
        omsOrderReturnApplyManager.delete(ids);
        return R.success("修改成功");
    }
}
